<?php
/**
 * @Name: NodeModel.php
 * @Author: yashuai
 */

namespace App\Http\Model\Rbac;

use Illuminate\Support\Facades\DB;

class NodeModel extends BaseModel
{

    protected $table = 'admin_node';

    /**
     * @Desc 获取用户所有菜单节点ID数组
     * @param int $userId
     * @return array
     * @author yashuai
     */
    public static function getUserNodeIDArray($userId=0)
    {
        return DB::table(RoleNodeModel::tableName() . ' as n')
            ->leftJoin(UserRoleModel::tableName() . ' as r', 'n.RoleID', '=', 'r.RoleID')
            ->where('r.UserID', '=', $userId)
            ->pluck('n.NodeID')->toArray();
    }

}
